-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat: add custom base URL support for VertexAI provider #7900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add vertexBaseUrl field to provider settings schema - Update VertexHandler to use custom base URL via GeminiHandler - Update AnthropicVertexHandler to use custom base URL - Add UI checkbox and input field for custom base URL in Vertex.tsx - Add comprehensive tests for the new functionality Fixes #7899
src/api/providers/gemini.ts
Outdated
|
|
||
| // Use vertexBaseUrl if this is a Vertex handler, otherwise use googleGeminiBaseUrl | ||
| const baseUrl = | ||
| this.constructor.name === "VertexHandler" ? this.options.vertexBaseUrl : this.options.googleGeminiBaseUrl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using this.constructor.name === "VertexHandler" to detect a Vertex handler is brittle (e.g. it may break under minification). Consider using the provided isVertex flag (or another dedicated property) to decide which base URL to use.
| tools.push({ googleSearch: {} }) | ||
| } | ||
|
|
||
| // Use vertexBaseUrl if this is a Vertex handler, otherwise use googleGeminiBaseUrl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same base URL selection logic is repeated in both createMessage and completePrompt. Consider refactoring this logic into a shared helper to reduce duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewing my own code is like debugging in production - technically possible but morally questionable.
- Replace 'any' type with proper VertexOptions type in anthropic-vertex.ts - Use isVertex property instead of fragile constructor.name comparison in gemini.ts - Improve test assertions clarity by checking undefined explicitly
|
This doesn't seem to be working, I can't see the Custom URL field |
Summary
This PR adds support for custom base URLs in the VertexAI provider, enabling users to proxy LLM API calls through an API gateway for per-user virtual API keys and usage reporting.
Changes
vertexBaseUrlfield to provider settings schemaTesting
Screenshots
The UI now includes a checkbox to enable custom base URL with an input field (similar to OpenAI and other providers):
Fixes #7899
Important
Adds custom base URL support for VertexAI provider, updating schema, handlers, UI, and tests.
vertexBaseUrltovertexSchemainprovider-settings.tsfor custom base URL support.AnthropicVertexHandlerandGeminiHandlerto use custom base URL if provided.Vertex.tsxnow includes a checkbox and input for custom base URL.anthropic-vertex.spec.tsandvertex.spec.tsto verify custom base URL functionality.GeminiHandlerandAnthropicVertexHandlerconstructors to handlevertexBaseUrl.This description was created by
for 1698100. You can customize this summary. It will automatically update as commits are pushed.